<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="defineProduct.model.ItemBean" %>
<%@ page import="java.util.Set" %>
<%@ page import="java.util.Map" %>
<% ItemBean item = (ItemBean) session.getAttribute("item"); 
Set<Long> itemSizes = item.getSizes();
Map<Long,String> sizes = (Map<Long, String>)session.getAttribute("sizes");
%>
<!DOCTYPE html >

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Описание на размери</title>
<link rel="stylesheet" href="/Store/css/Administration.css" type="text/css">
<script src="jquery-2.1.1.min.js"> </script>
<script>

function addElement(className){
    
    var parentHTML = $("."+className).filter(":first").html();
    var child = document.createElement("tr");
    child.innerHTML = parentHTML;
    var removeButton = document.createElement("button");
    text = document.createTextNode("Премахни");
    removeButton.appendChild(text);
    $(removeButton).attr("type","button");
    $(removeButton).click(function(){
       $(this).parent().remove();
    
    });
    child.appendChild(removeButton);
    $(child).attr("class",className);
    $("."+className).filter(":last").after(child);
    
}
</script>
</head>
<body>
<div class="container">
<div class="main">
<form action="/Store/DescribeSizes4" autocomplete="off" method="post">
<table class="center">
<tr>
<% for(long sizeId: itemSizes){ %>
<td style="text-align: center"> <%=sizes.get(sizeId) %></td>

<% } %>
</tr>

<tr class="sizes"> 
<% for(long sizeId: itemSizes){ %>
<td> <input type="text" required name="<%= ""+sizeId+"[]" %>">  </td>

<% } %>
<td> <button type="button" onclick="addElement('sizes')"> Добави </button> </td>
</tr>

<tr>
<td> <input type="submit" value="Завърши"> </td> 
<td class="cancel"> <a href="/Store/Supplier.html"> <button type="button"> Отмени </button> </a></td>	
</tr>
</table>
</form>
</div>
</div>
</body>
</html>